package cn.org.timespace.ons.action.policy;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.org.timespace.easyframe.action.EFBaseAction;
import cn.org.timespace.easyframe.service.permission.OperationLogService;

import cn.org.timespace.ons.service.policy.DataContentsService;
import cn.org.timespace.ons.util.pager.Pager;
import cn.org.timespace.ons.util.pager.PagerHelper;


public class DataContentsAction extends EFBaseAction{
	
	private static Log log = LogFactory.getLog(DataContentsAction.class);
	private DataContentsService dataContentsService;
	private OperationLogService operationLogService;
	public DataContentsService getDataContentsService() {
		return dataContentsService;
	}
	public void setDataContentsService(DataContentsService dataContentsService) {
		this.dataContentsService = dataContentsService;
	}
	public DataContentsAction()
	{
		super(new DataContentsModel());
	}
	
	
	
	DataContentsModel dataContentsModel = (DataContentsModel) this.getModel();
	
	
	
	/**
	 * 信息终端用户显示数据列表
	 * @return
	 * @throws Exception
	 */
	public String doList() throws Exception{
		
		Pager p = PagerHelper.getPagerInstance(getRequest());
		List<Object> resList = dataContentsService.findByCondition(dataContentsModel,getUserAccount(),p);
		
		if(resList != null && resList.size() == 2){
			p.setTotalCount(((Integer)resList.get(0)));
			p.setData((List)resList.get(1));
		}
		return LIST;
	}
	
	/**
	 * 应用平台用户显示数据列表
	 * @return
	 * @throws Exception
	 */
	public String doListByAp() throws Exception{
		
		Pager p = PagerHelper.getPagerInstance(getRequest());
		List<Object> resList = dataContentsService.findByConditionAp(dataContentsModel,getUserAccount(),p);
		
		if(resList != null && resList.size() == 2){
			p.setTotalCount(((Integer)resList.get(0)));
			p.setData((List)resList.get(1));
		}
		return LIST;
	}
	
	
}

